﻿@page "/comic/author/{Id}"

@using HentaiBlazor.Data.Comic
@using HentaiBlazor.Ezcomp

@inject NavigationManager NavigationManager

<PageContainer Title="@authorEntity.Name">
    <Space Style="margin-bottom: 0.5rem;">
        <SpaceItem>
            <Button Type="@buttonAllType()" Size="@ButtonSize.Small" OnClick="OnAll">全部</Button>
        </SpaceItem>
        <SpaceItem>
            @foreach (var author in authorEntities)
            {
                <Button Type="@buttonAuthorType(author.Id)" Size="@ButtonSize.Small" 
                        OnClick="() => OnAuthor(author.Id)">@author.Name</Button>
            }
        </SpaceItem>
    </Space>

    <AntList ItemLayout="ListItemLayout.Horizontal"
             Grid="gutter" DataSource="bookEntities">
        <ListItem Grid="gutter">
            <CardBook Book="@context" OnDetail="() => OpenDetail(context.Id, context.Title)"></CardBook>
        </ListItem>
    </AntList>
</PageContainer>

@code {

    public ListGridType gutter = new ListGridType
    {
        Gutter = 8,
        Xs = 2,
        Sm = 2,
        Md = 4,
        Lg = 4,
        Xl = 5,
        Xxl = 5,
        Column = 10
    };

    private string buttonAllType()
    {
        return All ? ButtonType.Primary : ButtonType.Default;
    }

    private string buttonAuthorType(string id)
    {
        return id == authorEntity.Id ? (All ? ButtonType.Default : ButtonType.Primary) : ButtonType.Dashed;
    }

}
